<script type="text/javascript">
	function initialize() {
		
		<?php
			if ( isset($arr_location_info['groom']['lat']) && isset($arr_location_info['groom']['lon']) )
				echo "var gr_location = new google.maps.LatLng(".$arr_location_info['groom']['lat'].",". $arr_location_info['groom']['lon'].");";
			else
				echo "var gr_location = new google.maps.LatLng(10.8152328, 106.680505);";
			
			if ( isset($arr_location_info['groom']['title']) )
				echo "var gr_string = '".$arr_location_info['groom']['title']."';";
			else
				echo "var gr_string = 'Vị trí bạn đã chọn';";

			if ( isset($arr_location_info['bride']['lat']) && isset($arr_location_info['bride']['lon']) )
				echo "var br_location = new google.maps.LatLng(".$arr_location_info['bride']['lat'].",". $arr_location_info['bride']['lon'].");";
			else
				echo "var br_location = new google.maps.LatLng(10.8152328, 106.680505);";			
			
			if ( isset($arr_location_info['bride']['title']) )
				echo "var br_string = '".$arr_location_info['bride']['title']."';";
			else
				echo "var br_string = 'Vị trí bạn đã chọn';";
		?>

        var gr_Options = {        	
			center : gr_location,
          	zoom: 16,
          	mapTypeId: google.maps.MapTypeId.ROADMAP
        };

        var gr_map = new google.maps.Map(document.getElementById("groom_location"),
            gr_Options);
        
        gr_marker = new google.maps.Marker({
			map:gr_map,
			draggable:true,
			animation: google.maps.Animation.DROP,
			position: gr_location,
			title : gr_string
		});

		var gr_latlng = new google.maps.LatLng();
		
		google.maps.event.addListener(gr_marker, 'dragend', function(){
			gr_latlng = gr_marker.getPosition();
			$('#txt_groom_lat').val(gr_latlng.lat());
			$('#txt_groom_long').val(gr_latlng.lng());
		});

		var br_Options = {        	
			center : br_location,
          	zoom: 16,
          	mapTypeId: google.maps.MapTypeId.ROADMAP
        };

        var br_map = new google.maps.Map(document.getElementById("bride_location"),
            br_Options);
        
        br_marker = new google.maps.Marker({
			map:br_map,
			draggable:true,
			animation: google.maps.Animation.DROP,
			position: br_location,
			title : br_string
		});

		var br_latlng = new google.maps.LatLng();
		
		google.maps.event.addListener(br_marker, 'dragend', function(){
			br_latlng = br_marker.getPosition();
			$('#txt_bride_lat').val(br_latlng.lat());
			$('#txt_bride_long').val(br_latlng.lng());
		});
    }
    
	head.ready(function() {
		initialize();
	});
	
	
</script>
<div class="left content_right">
	<div style="height:400px">
		<?php echo _LB_GROOM_LOCATION;
			$v_groom_title = '';
			if ( isset($arr_location_info['groom']['title']) )
				$v_groom_title = $arr_location_info['groom']['title'];
		?> 
		<input type="text" class="input" name="txt_groom_location" id="txt_groom_location" value="<?php echo $v_groom_title;?>">
		<input type="hidden" name="txt_groom_lat" id="txt_groom_lat">
		<input type="hidden" name="txt_groom_long" id="txt_groom_long">
		<a href='javascript:void(0);' class="button blue" onclick="addLocation('<?php echo GROOM_LOCATION;?>');"><span class="label"><?php echo _LB_UPDATE;?></span></a>
		<div class="clear">&nbsp;</div>	
		<div id="groom_location" style="width:700px; height:300px; position:relative; margin:10px; border:1px #b1c4d5 solid;"></div>
	</div>
	<div class="clear">&nbsp;</div>	
	<div style="height:400px">
		<?php echo _LB_BRIDE_LOCATION; 
			$v_bride_title = '';
			if ( isset($arr_location_info['bride']['title']) )
				$v_bride_title = $arr_location_info['bride']['title'];
		?> 
		<input type="text" class="input" name="txt_bride_location" id="txt_bride_location" value="<?php echo $v_bride_title;?>">
		<input type="hidden" name="txt_bride_lat" id="txt_bride_lat">
		<input type="hidden" name="txt_bride_long" id="txt_bride_long">
		<a href='javascript:void(0);' class="button blue" onclick="addLocation('<?php echo BRIDE_LOCATION;?>');"><span class="label"><?php echo _LB_UPDATE;?></span></a>
		<div class="clear">&nbsp;</div>	
		<div id="bride_location" style="width:700px; height:300px; position:relative; margin:10px; border:1px #b1c4d5 solid;"></div>
		<div class="clear">&nbsp;</div>	
	</div>
</div>
<script type="text/javascript">
	
	function addLocation(type){
		var location_type = '';
		if (type == <?php echo GROOM_LOCATION; ?>)
			location_type = 'txt_groom';
		if (type == <?php echo BRIDE_LOCATION; ?>)
			location_type = 'txt_bride';
		lat = $('#'+location_type+'_lat').val();
		lon = $('#'+location_type+'_long').val();
		loca = $('#'+location_type+'_location').val();
		str_arr = { loca_type: type,lat: lat , lon: lon , loca: loca };
		if ( !callAjaxFunction( '<?php echo URL;?>?a=ACC&acc=USER&user=MAP&map=UL',str_arr ) )
			alert('error');
	}
	
</script>
<div class="clear">&nbsp;</div>
